{include file="header.htm" /}
<body class="bodystyle" style="overflow-y: scroll; cursor: default; -moz-user-select: inherit;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<style type="text/css">
    .red {color: red !important;}
</style>
<div class="page min-hg-c-50 pb50">
    <div class="flexigrid flexigrid-xin">
        <div class="header-bar">
            <div class="more">
                <div class="search">
                    <div class="content">
                        <form id="searchForm" action="{:weapp_url('PointsShop/PointsShop/selectGoods')}" method="get" onsubmit="layer_loading('正在处理');" style="display: unset;">
                            {$searchform.hidden|default=''}
                            <div class="ey-form-item"><label class="users-form-item-label">关键词：</label>
                                <div class="users-form-item-content">
                                    <div class="users-select">
                                        <div tabindex="0" class="users-select-selection">
                                            <div class="sDiv2">
                                                <input type="text" size="50" name="keywords" value="{$Request.param.keywords}" class="qsbox" style="width: 170px;" placeholder="商品名称">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
            
                            <div class="ey-form-item " style="position: relative !important;">
                                <label class="users-form-item-label">商品分类：</label>
                                <div class="users-form-item-content" id="goodsStypeid">
                                    <div class="users-select">
                                        <div class="users-select-selection">
                                            <div class="sDiv2">
                                                <select name="typeid" class="select" style="margin:0px 5px;">
                                                    <option value="">--所有栏目--</option>
                                                    {$arctype_html}
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
            
                            <div class="ey-form-item" style="margin-left: 20px;">
                                <div class="users-form-item-content">
                                    <span class="bt-xin" onclick="goodsQuery();">查询</span>
                                    <span class="bt-xin-no" onclick="goodsQuery('reset');">重置</span>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <div class="flexigrid">
        <div class="hDiv mt10">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0" style="width: 100%">
                    <thead>
                        <tr>
                            <th class=""><div class="text-l10">商品名称</div></th>
                            <th class="w180"><div class="text-l10">价格</div></th>
                            <th class="w160"><div class="text-l10">库存</div></th>
                            <th class="w120"><div class="tc">操作</div></th>
                        </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="bDiv" style="height: auto;">
            <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                <table style="width: 100%">
                    <tbody>
                    {empty name="list"}
                        <tr>
                            <td class="no-data" align="center" axis="col0" colspan="50">
                                <div class="no_row">
                                    <div class="no_pic"><img src="__SKIN__/images/null-data.png"></div>
                                </div>
                            </td>
                        </tr>
                    {else/}
                        {volist name="list" id="vo"}
                        <tr>
                            <td style="width: 100%;">
                                <div class="flex-row"><img width="60" height="60" src="{$vo.litpic}"><div class="ml5">{$vo.title}</div></div>
                            </td>
                            <td>
                                <div class="w180 text-l10"><strong>￥{$vo.users_price}</strong></div>
                            </td>
                            <td>
                                <div class="w160 text-l10">{$vo.stock_count}</div>
                            </td>
                            <td class="operation">
                                <div class="w120 tc">
                                    {eq name="$vo.goods_save" value="1"}
                                    <a href="JavaScript:void(0);" class="btn grey">选择</a>
                                    {else/}
                                    <a href="JavaScript:void(0);" data-aid="{$vo.aid}" onclick="selectGoods(this);" class="btn blue" id="goods_id_{$vo.aid}">选择</a>
                                    {/eq}
                                </div>
                            </td>
                        </tr>
                        {/volist}
                    {/empty}
                    </tbody>
                </table>
            </div>
            <div class="iDiv" style="display: none;"></div>
        </div>
        {notempty name="list"}
        <div class="tDiv">
            <div class="tDiv2">{include file="page.htm" /}</div>
        </div>
        {/notempty}

        <div class="bot3">
            <div class="item-selected">已选择<span id="selectLength" style="color: red">0</span>个商品</div>
            <a href="javascript:void(0);" onclick="submitSelectGoods();" class="ncap-btn-big ncap-btn-green"><span>确认</span></a>
            <a class="ncap-btn-big ncap-btn-no" href="javascript:void(0);" onclick="parent.closeSelectGoods(true);" title="关闭">关闭</a>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function() {
        // 加载已选商品数
        $('#selectLength').text(parent.aidArr.length);
        // 显示已选商品标记
        if (parent.aidArr.length > 0) {
            $.each(parent.aidArr, function(index, value) {
                if ($('#goods_id_' + value)) $('#goods_id_' + value).removeClass('blue').addClass('red').html('已选');
            });
        }
    });

    // 系统商品查询
    function goodsQuery(isReset) {
        if (isReset && 'reset' == isReset) {
            window.location.href = "{:weapp_url('PointsShop/PointsShop/selectGoods')}";
        } else {
            $('#searchForm').submit();
        }
    }

    // 点击选中商品
    function selectGoods(obj) {
        // 执行父级页面选中操作
        parent.selectGoods(obj);
        // 加载已选商品数
        $('#selectLength').text(parent.aidArr.length);
    }

    // 提交选中商品
    function submitSelectGoods() {
        // if (0 === parseInt(parent.aidArr.length)) {
        //     layer.alert('请选择商品', {icon: 0, title: false, closeBtn: false});
        //     return false;
        // }
        // 执行父级页面提交选中商品操作
        parent.submitSelectGoods();
    }

</script>
{include file="footer.htm" /}
